<?php
/*=============================================================================
|| ##################################################################
||	phpFoX Konsort
|| ##################################################################
||
||	Copyright		: (C) 2005-2007 PHPFOX Limited a Reality Fox Creation
||	Contact			: info@phpfox.com
||
||	- phpFoX and all of its source code and files are protected by Copyright Laws.
||
||	- The license for phpFoX permits you to install this software on a single domain (.com, .org, .net, etc.).
||
||	- You may also not remove this copyright screen which shows the copyright information and credits for phpFoX (RealityFOX Creations).
||
||	- phpFoX Konsort is NOT a FREE software - http://www.phpfox.com/license/
||
|| ##################################################################
=============================================================================*/

/* $File: ./include/init.inc.php, $Author:  $ */

/**
 * Check if we should start a session
 */
if (!defined("bNoSession"))
{
	session_start();
}

/**
 * Defines that we are running phpFoX
 * @package core
 */
define("phpfoxInit", true);

/**
 * Uses cache routine
 * @package core
 */
define("phpfoxCache", true);

/**
 * Uses SQL row cache routine
 * @package core
 */
define("phpfoxSqlRowCache", true);

/**
 * Defines if we should use the development mode
 * @package core
 */
define("phpfoxDevMode", false);

/**
 * Under debug mode this will explain SQL queries
 * @package core
 */
define("phpfoxDevMysqlExplain", false);

/**
 * Check if SMARTY should be checked before it complies a new page.
 * Set this feature to false and your site will speed up.
 * @package core
 */
define("compile_check", true);

define('CAN_SET_COOKIE', (isset($_COOKIE['PHPSESSID']) ? true : false));

define('PHPFOX_USE_DEFAULT', false);
define('PHPFOX_DEFAULT_IPS', '');
define('PHPFOX_DEFAULT_LOCATION', 'plugins/default-files/');
if (PHPFOX_USE_DEFAULT && file_exists(dirname(dirname(__FILE__)) . '/' . PHPFOX_DEFAULT_LOCATION . 'include/classes/App.class.php'))
{
	if (PHPFOX_DEFAULT_IPS != '')
	{
		$aParts = split(',', PHPFOX_DEFAULT_IPS);
		foreach($aParts as $sIp)
		{
			if (trim($sIp) == $_SERVER['REMOTE_ADDR'])
			{
				define('PHPFOX_NO_PLUGINS', true);
				define('PHPFOX_DEFAULT_DIR', PHPFOX_DEFAULT_LOCATION);
				break;
			}
		}
	}
	else 
	{
		define('PHPFOX_NO_PLUGINS', true);
		define('PHPFOX_DEFAULT_DIR', PHPFOX_DEFAULT_LOCATION);
	}
}

if (!defined('PHPFOX_DEFAULT_DIR'))
{
	define('PHPFOX_DEFAULT_DIR', '');
}

/**
 * Set the memory limit
 */
ini_set('memory_limit', '42M');

define('PHPFOX_INCLUDE', dirname(dirname(__FILE__)).'/' . PHPFOX_DEFAULT_DIR . 'include/');

/**
 * Set the full include path
 */
ini_set('include_path', '.'.PATH_SEPARATOR . PHPFOX_INCLUDE);

if (!defined("PHPFOX_NO_OB_START"))
{
	ob_start();
}

/**
 * Load the core settings
 */
if (file_exists(str_replace(PHPFOX_DEFAULT_DIR, '', PHPFOX_INCLUDE) . 'settings/server.sett.php'))
{
	require_once str_replace(PHPFOX_DEFAULT_DIR, '', PHPFOX_INCLUDE) . 'settings/server.sett.php';
}
require_once PHPFOX_INCLUDE . 'settings/common.sett.php';

/**
 * Load the debug functions if we have not turned off the option
 */
if ( !defined("bNoDebugMode") )
{
	require_once PHPFOX_INCLUDE . 'debug.inc.php';
}

/**
 * Load the core classes/functions
 */
require_once PHPFOX_INCLUDE . 'settings/version.php';
require_once PHPFOX_INCLUDE . 'settings/tables.sett.php';
require_once PHPFOX_INCLUDE . 'settings/url.sett.php';
require_once PHPFOX_INCLUDE . 'classes/Object.class.php';
require_once PHPFOX_INCLUDE . 'classes/database/'. dbClass .'/Database.class.php';
require_once PHPFOX_INCLUDE . 'classes/BaseModule.class.php';
require_once PHPFOX_INCLUDE . 'classes/BaseService.class.php';
require_once PHPFOX_INCLUDE . 'classes/BaseComponent.class.php';
require_once PHPFOX_INCLUDE . 'classes/Cache.class.php';
require_once PHPFOX_INCLUDE . 'classes/database/'. dbClass .'/DbItem.class.php';
require_once PHPFOX_INCLUDE . 'classes/App.class.php';
require_once PHPFOX_INCLUDE . 'classes/file/File.class.php';
require_once PHPFOX_INCLUDE . 'classes/Language.class.php';

if ( !defined('bNoSmarty') )
{
	require_once PHPFOX_INCLUDE . 'classes/smarty/Smarty.class.php';
}

// Load the special directory module
App::loadModuleDir();

// Load all the config. settings
App::loadSettings();

// Load the language class
$oLang =& App::getLanguage();

// Require core config file
require_once(cachedDir . Cache::fName(App::getParam('cache.config')));

if (App::getParam('use_gzip'))
{
	$_CONF['use_gzip'] = false;
	if (isset($_SERVER['HTTP_ACCEPT_ENCODING']))
	{
		$encodings = explode(',', strtolower(preg_replace("/\s+/", "", $_SERVER['HTTP_ACCEPT_ENCODING'])));
		if ((in_array('gzip', $encodings) || in_array('x-gzip', $encodings) || isset($_SERVER['---------------'])) && function_exists('ob_gzhandler') && !ini_get('zlib.output_compression') && !headers_sent()) 
		{
			$_CONF['use_gzip'] = true;
		}
	}	
}

if (!App::getParam('rewrite_engine'))
{
	$_CONF['path_translated'] = false;
}

// Load the plug-in class
require_once App::getParam('path') . 'include/classes/Plugins.class.php';

ob_clean();

header('Content-Type: text/html; charset='. $oLang->aLanguage['charset'] .'');

define('XAJAX_DEFAULT_CHAR_ENCODING', $oLang->aLanguage['charset']);

(($sHook = App::getHook('Init')) ? eval($sHook) : false);

?>